Skip to content

feat: Add full Taxonomy and Terms API to .NET CMA SDK#138

Merged
OMpawar-21 merged 3 commits intodevelopmentfrom
enhc/DX-4914
Mar 11, 2026
Merged

feat: Add full Taxonomy and Terms API to .NET CMA SDK#138
OMpawar-21 merged 3 commits intodevelopmentfrom
enhc/DX-4914

Conversation

@OMpawar-21
Copy link

Summary

Implements the full Taxonomy and Terms API in the .NET Contentstack Management SDK to align with the JavaScript CMA SDK. Supports managing taxonomies and their terms (CRUD, export, locales, localize, import; term hierarchy, move, search).


Changes

New Models

File Description
TaxonomyModel.cs Taxonomy payload/response (Uid, Name, Description, Locale, counts, CreatedAt, UpdatedAt, Uuid) with snake_case JSON properties
TermModel.cs Term payload/response; includes TermAncestorDescendant and TermMoveModel (ParentUid, Order) for hierarchy and move
TaxonomyImportModel.cs Implements IUploadInterface for taxonomy import (multipart form key "taxonomy"; file path or Stream + filename)

Taxonomy API (Taxonomy.cs)

  • Extends BaseModel<TaxonomyModel> with resourcePath /taxonomies or /taxonomies/{uid}, fieldName "taxonomy".
  • CRUD: Create, CreateAsync, Update, UpdateAsync, Fetch, FetchAsync, Delete, DeleteAsync (optional ParameterCollection).
  • Query: Query() returns Query for listing taxonomies.
  • Export: GET {resourcePath}/export (sync/async).
  • Locales: GET {resourcePath}/locales (sync/async).
  • Localize: POST with body { taxonomy: model } and query params (sync/async).
  • Import: POST /taxonomies/import via UploadService with TaxonomyImportModel (sync/async).
  • Terms: Terms(termUid = null) returns Term (requires taxonomy Uid; used for single term or term collection).

Term API (Term.cs)

  • Extends BaseModel<TermModel> with resourcePath /taxonomies/{taxonomyUid}/terms or .../terms/{termUid}, fieldName "term".
  • CRUD: Create, CreateAsync, Update, UpdateAsync, Fetch, FetchAsync, Delete, DeleteAsync.
  • Query: Query() for listing terms (when no term Uid).
  • Ancestors / Descendants: GET .../ancestors and .../descendants (sync/async).
  • Move: PUT .../move with TermMoveModel (sync/async).
  • Locales: GET .../locales (sync/async).
  • Localize: POST with body { term: model } and query params (sync/async).
  • Search: GET /taxonomies/$all/terms with typeahead query param (sync/async; only when no term Uid).

Stack Entry Point

  • Stack.cs: public Taxonomy Taxonomy(string uid = null) with ThrowIfNotLoggedIn and ThrowIfAPIKeyEmpty; XML docs and example.

Services

  • UploadService.cs: Optional ParameterCollection for query string on upload (used by Taxonomy Import).
  • All other operations use existing CreateUpdateService, FetchDeleteService, QueryService.

Unit Tests

  • TaxonomyTest.cs – Init (no uid / with uid), Create, Query, Fetch, Get Terms collection, Get single Term (10 tests).
  • TermTest.cs – Init collection / with uid, Create, Query, Fetch, Search (10 tests).
  • Uses _stack.Taxonomy() / _stack.Taxonomy(uid) and _stack.Taxonomy(taxonomyUid).Terms() / .Terms(termUid); mock client and MockResponse.txt.

Integration Tests

  • Contentstack017_TaxonomyTest.cs – Create, Fetch, Query, Update, FetchAsync, Delete (6 tests, [DoNotParallelize]).
  • Models.cs (Tests): TaxonomyResponseModel and TaxonomiesResponseModel for API response parsing.
  • Fix: Use static taxonomy UID so the same taxonomy created in Test001 is used by Fetch/Update/Delete tests (avoids ContentstackErrorException from operating on non-existent UIDs).

Testing

  • Unit: 20 Taxonomy/Term tests passing.
  • Integration: Contentstack017_TaxonomyTest runs against live API when credentials are configured (create → fetch → query → update → fetch async → delete).

Files Changed

Action Path
Add Contentstack.Management.Core/Models/TaxonomyModel.cs
Add Contentstack.Management.Core/Models/TermModel.cs
Add Contentstack.Management.Core/Models/TaxonomyImportModel.cs
Add Contentstack.Management.Core/Models/Taxonomy.cs
Add Contentstack.Management.Core/Models/Term.cs
Modify Contentstack.Management.Core/Models/Stack.cs
Modify Contentstack.Management.Core/Services/Models/UploadService.cs
Add Contentstack.Management.Core.Unit.Tests/Models/TaxonomyTest.cs
Add Contentstack.Management.Core.Unit.Tests/Models/TermTest.cs
Add Contentstack.Management.Core.Tests/IntegrationTest/Contentstack017_TaxonomyTest.cs
Modify Contentstack.Management.Core.Tests/Model/Models.cs

- Add Taxonomy and Term support to match the JavaScript CMA SDK.

Models:
- TaxonomyModel, TermModel (with TermAncestorDescendant, TermMoveModel), TaxonomyImportModel (IUploadInterface for multipart import).

Taxonomy:
- CRUD, Query(), Export(), Locales(), Localize(), Import(), Terms(termUid).
- Stack.Taxonomy(uid) entry point.

Term:
- CRUD, Query(), Ancestors(), Descendants(), Move(), Locales(), Localize(), Search(typeahead).
- Accessed via Stack.Taxonomy(taxonomyUid).Terms() / .Terms(termUid).

Services:
- Reuse CreateUpdateService, FetchDeleteService, QueryService; extend UploadService with optional query params for Import.

Tests:
- Unit: TaxonomyTest, TermTest (20 tests). Integration: Contentstack017_TaxonomyTest (create, fetch, query, update, delete). Use static taxonomy UID in integration test so all steps use the same created taxonomy.
@OMpawar-21 OMpawar-21 requested a review from a team as a code owner March 10, 2026 09:58
@OMpawar-21 OMpawar-21 requested a review from cs-raj March 10, 2026 09:58
@OMpawar-21 OMpawar-21 changed the base branch from development to fix/test-cases March 10, 2026 10:02
sunil-lakshman
sunil-lakshman previously approved these changes Mar 10, 2026
@sunil-lakshman sunil-lakshman self-requested a review March 10, 2026 15:48
cs-raj
cs-raj previously approved these changes Mar 11, 2026
@OMpawar-21 OMpawar-21 changed the base branch from fix/test-cases to development March 11, 2026 07:04
@OMpawar-21 OMpawar-21 dismissed stale reviews from cs-raj and sunil-lakshman March 11, 2026 07:04

The base branch was changed.

@github-actions
Copy link

🔒 Security Scan Results

ℹ️ Note: Only vulnerabilities with available fixes (upgrades or patches) are counted toward thresholds.

Check Type Count (with fixes) Without fixes Threshold Result
🔴 Critical Severity 0 0 10 ✅ Passed
🟠 High Severity 0 0 25 ✅ Passed
🟡 Medium Severity 0 0 0 ✅ Passed
🔵 Low Severity 0 0 0 ✅ Passed

⏱️ SLA Breach Summary

✅ No SLA breaches detected. All vulnerabilities are within acceptable time thresholds.

Severity Breaches (with fixes) Breaches (no fixes) SLA Threshold (with/no fixes) Status
🔴 Critical 0 0 15 / 30 days ✅ Passed
🟠 High 0 0 30 / 120 days ✅ Passed
🟡 Medium 0 0 90 / 365 days ✅ Passed
🔵 Low 0 0 180 / 365 days ✅ Passed

✅ BUILD PASSED - All security checks passed

@OMpawar-21 OMpawar-21 merged commit 52dc968 into development Mar 11, 2026
10 of 11 checks passed
@OMpawar-21 OMpawar-21 deleted the enhc/DX-4914 branch March 11, 2026 07:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants